﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonEmpCertCodeValid.aspx.cs"
    Inherits="RN.ERP.Web.Person.PersonEmpCertCodeValid" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Styles/skins/blue/css/style.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery.min.js" type="text/javascript"></script>
    <link rel="Stylesheet" type="text/css" href="../Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.min.js"></script>
      <style type="text/css">
      .treeA
        {
            width:330px;
            height:300px;
            margin: 4px;
            border: 1px solid #ccc;
            overflow:auto;
        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="padding-left: 4px;">
        <div class="xian">
            <div class="about_title">
                证书类别选择</div>
            <div class="i-con-cn">
                <a href="javascript:void(0);" id="btnCancel" class="xtbiao">关闭</a> <a href="javascript:void(0);"
                    id="btnSelect" class="xtbiao">选择</a>
            </div>
        </div>
        <div>
            <ul id="treeCertType" class="treeA">
            </ul>
        </div>
    </div>
          <input id="hdManualID" type="hidden" runat="server" value="ZGZS" />
    </form>
</body>
</html>
<script type="text/javascript">
    var tree = null;
    var manager = null;
    var typeFlags;
    var certName;
    var Level;
    var CLCode;
    var manualID;
   /*页面加载事件*/
    $(function () {
        manualID = $("#<%= hdManualID.ClientID%>").val();
        GetTree();
        //关闭按钮事件
        $("#btnCancel").click(function () {
            returnToParent(0);
        });
        //选择按钮事件
        $("#btnSelect").click(function () {
            returnToParent(1);
        });
    });
    /*取得证书类别树*/
    function GetTree() {
        tree = $("#treeCertType").ligerTree({
            nodeWidth: 300,
            url: 'PersonEmpCertCodeValid.aspx?action=GetQualitiesDic&rootCode=' + manualID + '&parentId=0',
            attribute: ['Id', 'Title', 'Code', 'Pid'],
            idFieldName: 'Code',
            textFieldName: 'Title',
//            isLeaf: function (data) {
//                if (!data) return false;
//                return data.Pid != "0";
//            },
            delay: function (e) {
                var data = e.data;
                if (data.Pid == "0") {
                    return { url: 'PersonEmpCertCodeValid.aspx?action=GetQualitiesDic&rootCode=' + manualID + '&childRootCode=ZGDJ&parentId=' + data.Id }
                }
                return false;
            },
            checkbox: false,
            onSelect: onSelect,
            onClick:function(e){return false;}
        });
        manager = $("#treeCertType").ligerGetTreeManager();
    } 
    /*节点选择事件*/
    function onSelect(note) {
        if (note.data.children == undefined && note.data.Pid == "0") {
           // manager.loadData(note.target, "PersonEmpCertCodeValid.aspx?action=GetQualitiesDic&rootCode=ZGZS&childRootCode=ZGDJ&parentId=" + note.data.Id);
            manager.loadData(note.target, "PersonEmpCertCodeValid.aspx?action=GetQualitiesDic&rootCode=" + manualID + "&childRootCode=ZGDJ&parentId=" + note.data.Id);
        }
        //选择的一级节点
       // if (note.target.outlinelevel == 1) {
        if (note.data.Pid == "0") {
            typeFlags = note.data.Code;
            certName = note.data.Title;
            Level = "-1";
            CLCode = "不分等级";
        } else {
           //二级节点
            var parentNote = tree.getParentTreeItem(note.target);
            typeFlags = parentNote.Code;
            certName = parentNote.title;
            Level = note.data.Code;
            CLCode = note.data.Title;          
        }
    }
    /*选择按钮事件*/
    function returnToParent(result) {
        var oArg = {};
        oArg.Result = result;
        if (result > 0) {
            var selNote = tree.getSelected();
            if (!selNote) {
                OpenAlert("请选择证书类别！");
                return false;
            }
            if (selNote.data.children != undefined) {
                OpenAlert("请选择证书等级！");
                return false;
            }
//            alert(selNote.data.children);
//            childCount = $("ul", $(selNote.target)).length;
//            if (childCount > 0) {
//                alert("请选择证书等级！");
//                return false;
//            }
            //返回数据
            oArg.typeFlags = typeFlags;
            oArg.certName = certName;
            oArg.Level = Level;
            oArg.CLCode = CLCode;  
        }
        //alert(oArg.typeFlags + oArg.certName + oArg.Level + oArg.CLCode + oArg.typeId);
       closeCertChildWin(oArg);
   }
    /*关闭窗口事件*/
    function closeCertChildWin(oArg) {
            parent.window.OnClientCloseCertType(oArg);
            window.parent.$.ligerDialog.close(); ////关闭dialog
            parent.$(".l-dialog,.l-window-mask").hide(); ////去除父窗体遮罩层
            parent.window.focus(); //返回焦点
        }
        function OpenAlert(text) {
            $.ligerDialog.warn(text);
            return false;
        }
</script>
